package kibahed.university.effizientealgorithmen.standardclasses;

import kibahed.university.effizientealgorithmen.interfaces.IEdgeCosts;
import kibahed.university.effizientealgorithmen.interfaces.IVertex;

/**
 * 
 * @author Bernhard Kinast
 * @author Daniel Heily
 *
 */

public class EdgeWithCosts implements IEdgeCosts, Comparable<EdgeWithCosts>{
	

	int end =-1;
	int start = -1;
	double cost =-1;
	IVertex startVertex = null;
	IVertex endVertex = null;
	
	@Override
	public int getEnd() {
		return end;
	}

	@Override
	public void setEnd(int destination) {
		this.end=destination;
		
	}

	@Override
	public void setCost(double cost) {
		this.cost=cost;
		
	}

	@Override
	public double getCost() {
		return cost;
	}

	@Override
	public int getStart() {
		return start;
	}

	@Override
	public void setStart(int start) {
		this.start=start;
	}

	@Override
	public int compareTo(EdgeWithCosts o) {
		if(cost < o.cost) {
			return -1;
		} else if(cost == o.cost) {
			return 0;
		} else {
			return 1;
		}
	}

	@Override
	public IVertex getStartVertex() {
		return startVertex;
	}

	@Override
	public IVertex getEndVertex() {
		return endVertex;
	}

	@Override
	public void setStartVertex(IVertex startVertex) {
		
		this.startVertex = startVertex;
		
	}

	@Override
	public void setEndVertex(IVertex endVertex) {
		this.endVertex = endVertex;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Math.min(start, end);
		result = prime * result + Math.max(start, end);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EdgeWithCosts other = (EdgeWithCosts) obj;
		if (end == other.end && start == other.start)
			return true;
		return false;
	}

}
